#!/usr/bin/ruby
# -*- ruby -*-
#
# http://www.reddit.com/r/dailyprogrammer/comments/137f87/11142012_challenge_112_intermediatedate_sorting/

require 'date'

dates = STDIN.readlines.map { |d| d.strip }

d = dates.sort do |a, b|
    "YYYY MM DD hh:mm:ss"

    Date.strptime(a, "%Y %m %d %H:%M:%S") <=> Date.strptime(b, "%Y %m %d %H:%M:%S")
end.join("\n")

puts d
